Parser: Fix handling of syntax errors such as x =- 2
#7399
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Description
Most sequences of operator characters are lexed as a single operator; however, there is a special case when the last character is
-
in order to accept expressions such asx+-1
andx=-1
, which use a binary operator followed by a unary operator, in an unspaced subexpression.Due to this lexical special case, special handling is needed in the parser to reject some related invalid syntaxes, such as
x +- 1
andx =- 1
. This special handling was absent, resulting in reaching a debug assertion when such syntax errors were encountered (#7335). This PR corrects the assumption in parts of the parser that multiple consecutive operators cannot occur in unspaced subexpressions. See the newly-added test cases for examples of the rejected expressions.Important Notes
.enso
file in the repo, this PR does not change the parser's AST. If there are any regressions, they would relate to inputs that are poor style or syntax errors, both of which are not as thoroughly covered by .enso tests and library files.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.